package com.jifen.goods.controller;

import com.jifen.common.CommonResult;
import com.jifen.common.Result;
import com.jifen.goods.service.GoodsService;
import com.jifen.goods.vo.GoodsParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jf/{version}/goods")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    /**
     * 搜索商品
     * @param param
     * @return
     */
    @RequestMapping("/search")
    @ResponseBody
    public Result search(GoodsParam param) {
        return CommonResult.createSuccessResult(goodsService.search(param));
    }

    /**
     * 分类
     * @return
     */
    @RequestMapping("/getCate")
    @ResponseBody
    public Result getCate() {
        return CommonResult.createSuccessResult(goodsService.getCate());
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @RequestMapping("/detail")
    @ResponseBody
    public Result detail(int id) {
        return CommonResult.createSuccessResult(goodsService.detail(id));
    }

}
